package flc.ast;

import android.graphics.Color;
import android.view.View;
import android.webkit.WebView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.stark.riddle.lib.RiddleModule;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.ChallengeFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.ToolFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseNoModelWebViewActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        RiddleModule.init(null);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment=new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.llHome));
        listFragment.add(new FragmentViewBinder(ToolFragment.class,R.id.llTool));
        listFragment.add(new FragmentViewBinder(ChallengeFragment.class,R.id.llChallenge));
        listFragment.add(new FragmentViewBinder(MyFragment.class,R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()){
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.qmbk1);
                mDataBinding.tvHome.setTextColor(Color.parseColor("#313131"));
                break;
            case R.id.llTool:
                mDataBinding.ivTool.setImageResource(R.drawable.qssq1);
                mDataBinding.tvTool.setTextColor(Color.parseColor("#313131"));
                break;
            case R.id.llChallenge:
                mDataBinding.ivChallenge.setImageResource(R.drawable.zstz1);
                mDataBinding.tvChallenge.setTextColor(Color.parseColor("#313131"));
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.grzx1);
                mDataBinding.tvMy.setTextColor(Color.parseColor("#313131"));
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.qmbk2);
        mDataBinding.tvHome.setTextColor(Color.parseColor("#CCCCCC"));
        mDataBinding.ivTool.setImageResource(R.drawable.qssq2);
        mDataBinding.tvTool.setTextColor(Color.parseColor("#CCCCCC"));
        mDataBinding.ivChallenge.setImageResource(R.drawable.zstz2);
        mDataBinding.tvChallenge.setTextColor(Color.parseColor("#CCCCCC"));
        mDataBinding.ivMy.setImageResource(R.drawable.grzx2);
        mDataBinding.tvMy.setTextColor(Color.parseColor("#CCCCCC"));
    }

}